/*
 * Project it.battlehorse.rcp.tools
 * Created on Nov 18, 2005
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 * 
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 *
 * A copy of the LGPL is available also at
 * http://www.gnu.org/copyleft/lesser.html
 * 
 */
package it.battlehorse.rcp.tools.log.actions;

import it.battlehorse.rcp.tools.log.LogActivator;
import it.battlehorse.rcp.tools.log.views.ActorLogContentProvider;

import org.eclipse.jface.action.Action;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.ui.PlatformUI;

/**
 * The action which is responsible for deleting all the log items
 * 
 * @author battlehorse
 * @since Nov 27, 2005
 */
public class DeleteAllLogAction extends Action {

	private ActorLogContentProvider provider;
	
	public DeleteAllLogAction(ActorLogContentProvider provider) {
		this.provider = provider;
		
		super.setText("Delete &all log items");
		super.setImageDescriptor(
				LogActivator.getImageDescriptor("resources/deleteall.png"));
		super.setToolTipText("Delete all log items");		
	}
	
	@Override
	public void run() {
		
		boolean delete = MessageDialog.openQuestion(
				PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
				"Delete all log items",
				"Do you really want to delete all log items?");
			
		if (delete) {
			
			provider.clear();
		}
			
				
	}	
	
}
